import requests


#该文件作为参考
# 设置请求头
headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer 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'
}
print('请输入')
prompt=input()
# 设置请求参数

data = {

    'model': 'gpt-3.5-turbo-0301',
    'prompt': 'Hello, how are you?',
    'temperature': 0.7,
    'max_tokens': 50,
    'n': 1,
    'stop': ['\n'],
    "messages": [{"role": "user", "content": prompt}]

}

# 设置代理
proxies = {
    'http': 'http://127.0.0.1:7890/',
    'https': 'http://127.0.0.1:7890/'
}
#
#https://api.openai.com/v1/models
#https://api.openai.com/v1/engines/davinci-codex/completions
# 发送POST请求
response = requests.post('https://api.openai.com/v1/chat/completions', headers=headers, json=data, proxies=proxies)

# 输出结果
print(response.status_code)
print(response.json())
print(response.json()['message'])
